<feed xmlns='http://www.w3.org/2005/Atom'>
<title>Low-Battery-Yup/Low Battery Yup.d.xcodeproj, branch master</title>
<subtitle>Dismiss Mac OS X's low battery warning dialog with the keyboard</subtitle>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/'/>
<entry>
<title>Remove Credits.rtf</title>
<updated>2016-12-03T09:21:07+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-03T09:21:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=dc0237bd0b345408f1c5700dc562078ce1d32706'/>
<id>dc0237bd0b345408f1c5700dc562078ce1d32706</id>
<content type='text'>
Remove this file as it isn't relevant at this point. We'll go with the
simplified About panel instead.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Remove this file as it isn't relevant at this point. We'll go with the
simplified About panel instead.
</pre>
</div>
</content>
</entry>
<entry>
<title>Copy MASShortcut.framework to bundle Frameworks/ directory</title>
<updated>2016-12-03T09:00:03+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-03T09:00:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=e67e81a0b227e0453310a800cb70fdc147d561aa'/>
<id>e67e81a0b227e0453310a800cb70fdc147d561aa</id>
<content type='text'>
The framework was getting copied to Resources/, but the app was told to
look for it in Frameworks/, so it was crashing on launch.

Here's the error:

    Dyld Error Message:
      Library not loaded: @executable_path/../Frameworks/MASShortcut.framework/Versions/A/MASShortcut
      Referenced from: /Users/USER/Documents/*/Low Battery Yup.app/Contents/MacOS/Low Battery Yup
      Reason: image not found

Thank goodness for Console and logging and crash logs. Never would have
figured this out otherwise. Worked fine in Debug configuration and when
building for Release in Xcode. Just didn't work in the final archived
app. Works now though, phew!
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The framework was getting copied to Resources/, but the app was told to
look for it in Frameworks/, so it was crashing on launch.

Here's the error:

    Dyld Error Message:
      Library not loaded: @executable_path/../Frameworks/MASShortcut.framework/Versions/A/MASShortcut
      Referenced from: /Users/USER/Documents/*/Low Battery Yup.app/Contents/MacOS/Low Battery Yup
      Reason: image not found

Thank goodness for Console and logging and crash logs. Never would have
figured this out otherwise. Worked fine in Debug configuration and when
building for Release in Xcode. Just didn't work in the final archived
app. Works now though, phew!
</pre>
</div>
</content>
</entry>
<entry>
<title>Click the right spot on all screen sizes</title>
<updated>2016-12-03T05:22:17+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-03T05:22:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=9d91a7c908dc2261f2c3335875323c7088938204'/>
<id>9d91a7c908dc2261f2c3335875323c7088938204</id>
<content type='text'>
Previously, the point set to be clicked for the low battery alert was
only valid on a 13" 1440x900 screen. This change allows the click
functionality to work on any screen size.

I discovered in 954071bcc651ed5876d8ac0c3e8c253d4470c416 that I couldn't
use a percentage to get the height of the "OK" button.

But, the low battery alert uses `NSWindow`'s `-center` method, so I
thought up a hack to make a fake window, center it, and get the window's
frame dimensions. The fake window I create has the same (close enough)
dimensions as the low battery alert (measured from a screenshot).

I then use those dimensions to figure out where to click so that I'm
clicking in the right place on the "OK" button.

We also add a check to reinitialise the dimensions and reset the current
window if the main window has changed from what we thought it was. This
should allow the app to still work if you launch it from one display and
later plug in another as your main display where the low battery warning
will now appear.

We need to subtract the frame's Y coordinate from the screen height
because the frame origin uses standard bottom-left origin coordinates,
while `CGDisplayMoveCursorToPoint` uses top-left origin coordinates.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, the point set to be clicked for the low battery alert was
only valid on a 13" 1440x900 screen. This change allows the click
functionality to work on any screen size.

I discovered in 954071bcc651ed5876d8ac0c3e8c253d4470c416 that I couldn't
use a percentage to get the height of the "OK" button.

But, the low battery alert uses `NSWindow`'s `-center` method, so I
thought up a hack to make a fake window, center it, and get the window's
frame dimensions. The fake window I create has the same (close enough)
dimensions as the low battery alert (measured from a screenshot).

I then use those dimensions to figure out where to click so that I'm
clicking in the right place on the "OK" button.

We also add a check to reinitialise the dimensions and reset the current
window if the main window has changed from what we thought it was. This
should allow the app to still work if you launch it from one display and
later plug in another as your main display where the low battery warning
will now appear.

We need to subtract the frame's Y coordinate from the screen height
because the frame origin uses standard bottom-left origin coordinates,
while `CGDisplayMoveCursorToPoint` uses top-left origin coordinates.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add daemon to UI app bundle</title>
<updated>2016-12-02T19:35:08+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-02T19:35:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=d530afa9d01ead88c06a7b8fcd384758332e9751'/>
<id>d530afa9d01ead88c06a7b8fcd384758332e9751</id>
<content type='text'>
Add "Low Bettery Yup.d" to "Low Battery Yup"'s Target Dependencies and
copy the "Low Bettery Yup.d.app" bundle into "Low Battery Yup"'s bundle
resources.

This will allow us to distribute the daemon more easily so there's only
one app that users see instead of two. It also allows us to locate the
app more easily since it's contained within the UI app's application
bundle.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add "Low Bettery Yup.d" to "Low Battery Yup"'s Target Dependencies and
copy the "Low Bettery Yup.d.app" bundle into "Low Battery Yup"'s bundle
resources.

This will allow us to distribute the daemon more easily so there's only
one app that users see instead of two. It also allows us to locate the
app more easily since it's contained within the UI app's application
bundle.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add "Start at login" checkbox that [un]installs launch agent</title>
<updated>2016-12-02T18:00:19+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-02T18:00:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=a77a053f90a7b2588dbaabedbf25f908680f2f30'/>
<id>a77a053f90a7b2588dbaabedbf25f908680f2f30</id>
<content type='text'>
A new checkbox in the UI that asks whether the app should start at
login. Checking and unchecking the box moves a LaunchAgent plist into
and out of `~/Library/LaunchAgents/`. This plist file will define
instructions to start the daemon on login.

Also add a `DaemonLauncher` class that will launch or quit the daemon
when the checkbox is clicked.

Bug:
Currently the app always starts with the checkbox checked. That's not
what should happen. Instead, we should save the checkbox value to
`NSUserDefaults` so that it has the previous value when the program is
launched.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A new checkbox in the UI that asks whether the app should start at
login. Checking and unchecking the box moves a LaunchAgent plist into
and out of `~/Library/LaunchAgents/`. This plist file will define
instructions to start the daemon on login.

Also add a `DaemonLauncher` class that will launch or quit the daemon
when the checkbox is clicked.

Bug:
Currently the app always starts with the checkbox checked. That's not
what should happen. Instead, we should save the checkbox value to
`NSUserDefaults` so that it has the previous value when the program is
launched.
</pre>
</div>
</content>
</entry>
<entry>
<title>Cleanup xcodeproj after merge</title>
<updated>2016-12-01T18:16:47+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-01T18:16:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=9984853a24eb148742e5e60c8b9ad4961ad399c3'/>
<id>9984853a24eb148742e5e60c8b9ad4961ad399c3</id>
<content type='text'>
Reopened the Xcode project after this merge
1cf0b1458248b75c3270b3b6cc7edc643e810929 and Xcode updated the file.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reopened the Xcode project after this merge
1cf0b1458248b75c3270b3b6cc7edc643e810929 and Xcode updated the file.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'shortcut-config-UI'</title>
<updated>2016-12-01T18:15:55+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-01T18:15:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=1cf0b1458248b75c3270b3b6cc7edc643e810929'/>
<id>1cf0b1458248b75c3270b3b6cc7edc643e810929</id>
<content type='text'>
Conflicts:
	Low Battery Yup/en.lproj/MainMenu.xib
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Conflicts:
	Low Battery Yup/en.lproj/MainMenu.xib
</pre>
</div>
</content>
</entry>
<entry>
<title>Add Constants.h for `kPreferenceGlobalShortcut`</title>
<updated>2016-12-01T18:03:50+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-01T18:03:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=d9179f9a9b18ad73ca0fafb0e0e4f289f267b68d'/>
<id>d9179f9a9b18ad73ca0fafb0e0e4f289f267b68d</id>
<content type='text'>
Since `kPreferenceGlobalShortcut` was defined in two different files,
extract it to a single file that gets imported where it's needed so
we're not doubly defining the same string.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since `kPreferenceGlobalShortcut` was defined in two different files,
extract it to a single file that gets imported where it's needed so
we're not doubly defining the same string.
</pre>
</div>
</content>
</entry>
<entry>
<title>Able to get a shortcut from the MASShortcutView</title>
<updated>2016-12-01T11:58:56+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-01T11:58:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=a984e2dd951bcbfe5e3e6374213eb9a5fd5423cf'/>
<id>a984e2dd951bcbfe5e3e6374213eb9a5fd5423cf</id>
<content type='text'>
Fuck damn it finally freaking works! Damn, just had to take a 1.5 hour
nap after that.

We're finally able to extract a shortcut out of the MASShortcutView.

After trying a whole bunch of different things, I ultimately tried
opening the debugger and figured out that for whatever reason the
bindings weren't getting created and because of that my shortcut wasn't
getting saved in the user defaults.

Couldn't figure out how to get the binding to work even after includes
and whatnot.

Finally decided screw it I'm going to subclass the view and get the
shortcut and store it in `NSUserDefaults` myself. So that's what we're
going to do and this is the first step to getting that working.

Hoo boy.

Definitely need to vaccum the code after this.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fuck damn it finally freaking works! Damn, just had to take a 1.5 hour
nap after that.

We're finally able to extract a shortcut out of the MASShortcutView.

After trying a whole bunch of different things, I ultimately tried
opening the debugger and figured out that for whatever reason the
bindings weren't getting created and because of that my shortcut wasn't
getting saved in the user defaults.

Couldn't figure out how to get the binding to work even after includes
and whatnot.

Finally decided screw it I'm going to subclass the view and get the
shortcut and store it in `NSUserDefaults` myself. So that's what we're
going to do and this is the first step to getting that working.

Hoo boy.

Definitely need to vaccum the code after this.
</pre>
</div>
</content>
</entry>
<entry>
<title>Use DDHotKeyTextField in "Low Battery Yup"</title>
<updated>2016-11-19T14:18:06+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-11-19T14:18:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=e7b97eb3c2656cae4d173c41d2006c32735ddb82'/>
<id>e7b97eb3c2656cae4d173c41d2006c32735ddb82</id>
<content type='text'>
Add a text field to the MainMenu.xib primary window and use it to allow
users to type hotkeys. I'm thinking we might use this instead of
MASShortcut since I've been having trouble getting that to work
(couldn't figure out how to get a registered hotkey out of
NSUserDefaults).

This tool seems simpler, and could be just the ticket.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a text field to the MainMenu.xib primary window and use it to allow
users to type hotkeys. I'm thinking we might use this instead of
MASShortcut since I've been having trouble getting that to work
(couldn't figure out how to get a registered hotkey out of
NSUserDefaults).

This tool seems simpler, and could be just the ticket.
</pre>
</div>
</content>
</entry>
</feed>
